<?php
/**
 * 	Bushido
 *
 * @category   Bushido
 * @package    Bushido_App
 * @copyright  Copyright (c) 2008-2009 Nathan Keyes
 * @author Nathan Keyes
 * @version    $Id: Bootstrap.php 7 2009-11-07 15:54:13Z nkeyes $
 */

/**
 * 
 * @author Nathan Keyes
 *
 */
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initSession()
	{	
		
		$this->bootstrap('frontController');
		$this->bootstrap('dbmulticonnection');
		
		$appConfig = Zend_Controller_Front::getInstance()->getParam('appconfig');
		
		$sessionConfig = array
		(
			'name'           => 'bushido_session',
			'primary'        => 'bushido_session_id',
			'modifiedColumn' => 'modified',
			'dataColumn'     => 'data',
			'lifetimeColumn' => 'lifetime'
		);
		
		Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($sessionConfig));
		//Zend_Session::setOptions(array('cookie_lifetime' => $appConfig['remembermeseconds']));
		//Zend_Session::start();
		$now = Zend_Date::now()->toValue(Zend_Date::TIMESTAMP);
		
		$session = new Zend_Session_Namespace($appConfig['appname']);
		if($session->regeneratedAt + $appConfig['regeneratedelayseconds'] < $now)
		{
			//Zend_Session::rememberMe($appConfig['remembermeseconds']);
			$session->regeneratedAt = $now;
		}
		
		
		/*
		Zend_Session::registerValidator(new Zend_Session_Validator_HttpUserAgent());
		Zend_Session::registerValidator(new Bushido_Session_Validator_IpAddress());
		*/
		
	}
	
	protected function _initAutoload()
	{
		$autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default_', 'basePath' => APPLICATION_PATH . '/modules/default',));
		return $autoloader;
	}

	protected function _initApp()
	{
		Zend_Locale_Data::disableCache(true);
		$this->bootstrap('dbmulticonnection');
		
	}
}